package org.nullauthor.allthings.mods;

import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.resource.featuretoggle.FeatureFlag;
import net.minecraft.resource.featuretoggle.FeatureFlags;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import org.nullauthor.allthings.Allthings;
import org.nullauthor.allthings.gui.handler.EffectUpgradeScreenHandler;

public class ModScreenHandlerTypes {

    public static final ScreenHandlerType<EffectUpgradeScreenHandler> EFFECT_UPGRADE_SCREEN = register("effect_upgrade_screen", EffectUpgradeScreenHandler::new);

    private static <T extends ScreenHandler> ScreenHandlerType<T> register(String id, ScreenHandlerType.Factory<T> factory) {
        return Registry.register(Registries.SCREEN_HANDLER, id, new ScreenHandlerType<>(factory, FeatureFlags.VANILLA_FEATURES));
    }

    private static <T extends ScreenHandler> ScreenHandlerType<T> register(String id, ScreenHandlerType.Factory<T> factory, FeatureFlag... requiredFeatures) {
        return Registry.register(Registries.SCREEN_HANDLER, id, new ScreenHandlerType<>(factory, FeatureFlags.FEATURE_MANAGER.featureSetOf(requiredFeatures)));
    }

    public static void registerScreenTypes() {
        Allthings.LOGGER.info("Registering ScreenHandlerTypes");
    }
}
